Micron Document
🌎 rns.kin.earth git 🌍

Node / dev / reticulum / commits / 7347034

Commit 7347034f9a531ea08e683b0b2d0e9e76bd3e71e1


Parents : aef9e5b
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Signature : T66BB85Valid, signed by author
Date : 2026-08-23T22:27:53+02:00

Optimized outbound IFAC handling

Changes

1 files changed, 21 insertions(+), 0 deletions(-)


Diff

diff --git a/RNS/Transport.py b/RNS/Transport.py
index 3143047d..3160985e 100755
--- a/RNS/Transport.py
+++ b/RNS/Transport.py
@@ -1257,6 +1257,27 @@ class Transport:
def handle_outgoing_announces(outgoing):
for packet in sorted(outgoing, key=lambda p: p.hops): packet.send()
+ @staticmethod
+ def handle_outgoing_ifac(interface, raw):
+ # Calculate packet access code
+ ifac_size = interface.ifac_size
+ ifac = interface.ifac_identity.sign(raw)[-ifac_size:]
+
+ # Generate mask
+ mask = RNS.Cryptography.hkdf(length=len(raw) + ifac_size, derive_from=ifac,
+ salt=interface.ifac_key, context=None)
+
+ # Set IFAC flag and assemble new payload with IFAC
+ new_raw = bytes([raw[0] | 0x80, raw[1]]) + ifac + raw[2:]
+
+ # Mask header bytes and payload with a single bignum XOR, leaving
+ # the IFAC itself untouched, then ensure the IFAC flag is set.
+ n = len(new_raw)
+ x = int.from_bytes(new_raw, "big") ^ int.from_bytes(mask, "big")
+ if ifac_size: x ^= int.from_bytes(mask[2:2 + ifac_size], "big") << (8 * (n - 2 - ifac_size))
+ x |= 1 << (8 * n - 1)
+ return x.to_bytes(n, "big")
+
@staticmethod
def handle_outgoing_ifac_legacy(interface, raw):
# Calculate packet access code

Served by rngit 1.5.2 - Generated in 0.04s